package org.sdp.pearproject.controller;


import org.sdp.pearproject.controller.custom.*;
import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: EventsMemberController
 * @Description:
 * @Author: SDP
 * @Date: 2022-08-05
 * @Version: 1.0
 * Table: pear_events_member
 * Comment:
 * 日程-成员表
 */
@RestController
@RequestMapping(value = "/events_member")
public class EventsMemberController extends EventsMemberCustomController {
    static {
        addRequestClass("events_member", "add", "eventsMemberController", EventsMemberController.class, EventsMemberAddRequest.class);
        addRequestClass("events_member", "add_encrypt", "eventsMemberController", EventsMemberController.class, EventsMemberAddRequest.class);

        addRequestClass("events_member", "update", "eventsMemberController", EventsMemberController.class, EventsMemberUpdateRequest.class);
        addRequestClass("events_member", "update_encrypt", "eventsMemberController", EventsMemberController.class, EventsMemberUpdateRequest.class);

        addRequestClass("events_member", "delete", "eventsMemberController", EventsMemberController.class, EventsMemberDeleteRequest.class);
        addRequestClass("events_member", "delete_encrypt", "eventsMemberController", EventsMemberController.class, EventsMemberDeleteRequest.class);

        addRequestClass("events_member", "query", "eventsMemberController", EventsMemberController.class, EventsMemberQueryRequest.class);
        addRequestClass("events_member", "query_encrypt", "eventsMemberController", EventsMemberController.class, EventsMemberQueryRequest.class);

        addRequestClass("events_member", "list", "eventsMemberController", EventsMemberController.class, EventsMemberQueryRequest.class);
        addRequestClass("events_member", "list_encrypt", "eventsMemberController", EventsMemberController.class, EventsMemberQueryRequest.class);

        addRequestClass("events_member", "count", "eventsMemberController", EventsMemberController.class, EventsMemberQueryRequest.class);
        addRequestClass("events_member", "count_encrypt", "eventsMemberController", EventsMemberController.class, EventsMemberQueryRequest.class);

        addRequestClass("events_member", "stat", "eventsMemberController", EventsMemberController.class, EventsMemberQueryRequest.class);
        addRequestClass("events_member", "stat_encrypt", "eventsMemberController", EventsMemberController.class, EventsMemberQueryRequest.class);

    }

    @PostMapping("/add")
    public Integer addEventsMember(@MixRequestBody EventsMemberAddRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events_member", "add", request, callFromEncrypt);
        return super.addEventsMember(request);
    }

    @PostMapping("/add_encrypt")
    public String addEventsMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsMemberAddRequest request = (EventsMemberAddRequest) super.decrypt("events_member", "add_encrypt", strRequest, EventsMemberAddRequest.class);
        Integer result = addEventsMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/update")
    public Integer updateEventsMember(@MixRequestBody EventsMemberUpdateRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events_member", "update", request, callFromEncrypt);
        return super.updateEventsMember(request);
    }

    @PostMapping("/update_encrypt")
    public String updateEventsMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsMemberUpdateRequest request = (EventsMemberUpdateRequest) super.decrypt("events_member", "update_encrypt", strRequest, EventsMemberUpdateRequest.class);
        Integer result = updateEventsMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/delete")
    public Integer deleteEventsMember(@MixRequestBody EventsMemberDeleteRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events_member", "delete", request, callFromEncrypt);
        return super.deleteEventsMember(request);
    }

    @PostMapping("/delete_encrypt")
    public String deleteEventsMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsMemberDeleteRequest request = (EventsMemberDeleteRequest) super.decrypt("events_member", "delete_encrypt", strRequest, EventsMemberDeleteRequest.class);
        Integer result = deleteEventsMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/query")
    public EventsMemberQueryResponse queryEventsMember(@MixRequestBody EventsMemberQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("events_member", "query", request, callFromEncrypt);
      return super.queryEventsMember(request);
    }

    @PostMapping("/query_encrypt")
    public String queryEventsMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsMemberQueryRequest request = (EventsMemberQueryRequest) super.decrypt("events_member", "query_encrypt", strRequest, EventsMemberQueryRequest.class);
        EventsMemberQueryResponse result = queryEventsMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/list")
    public List<EventsMemberQueryResponse> listEventsMember(@MixRequestBody EventsMemberQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events_member", "list", request, callFromEncrypt);
        if (super.needTotal("events_member", "list", request)) {
            super.setTotal("events_member", "list", request, super.countEventsMember(request));
        }
        return super.listEventsMember(request);
    }

    @PostMapping("/list_encrypt")
    public String listEventsMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsMemberQueryRequest request = (EventsMemberQueryRequest) super.decrypt("events_member", "list_encrypt", strRequest, EventsMemberQueryRequest.class);
        List<EventsMemberQueryResponse> result = listEventsMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/count")
    public Integer countEventsMember(@MixRequestBody EventsMemberQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("events_member", "count", request, callFromEncrypt);
      return super.countEventsMember(request);
    }


    @PostMapping("/count_encrypt")
    public String countEventsMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsMemberQueryRequest request = (EventsMemberQueryRequest) super.decrypt("events_member", "count_encrypt", strRequest, EventsMemberQueryRequest.class);
        Integer result = countEventsMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/stat")
    public BaseStatResponse statEventsMember(@MixRequestBody EventsMemberQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events_member", "stat", request, callFromEncrypt);
        return super.statEventsMember(request);
    }

    @PostMapping("/stat_encrypt")
    public String statEventsMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsMemberQueryRequest request = (EventsMemberQueryRequest) super.decrypt("events_member", "stat_encrypt", strRequest, EventsMemberQueryRequest.class);
        BaseStatResponse result = statEventsMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }


}
